package br.com.kariri.smartschool.ui.util.window
{
	import flash.display.DisplayObject;
	import flash.events.Event;
	import flash.events.TimerEvent;
	import flash.utils.Timer;
	import flash.utils.setTimeout;
	
	import mx.containers.Panel;
	import mx.controls.Alert;
	import mx.core.Application;
	import mx.effects.Fade;
	import mx.effects.WipeDown;
	import mx.effects.WipeUp;
	import mx.effects.Zoom;
	import mx.managers.PopUpManager;
	
	/**
	 * Painel de notificacao. Sendo configurado para ser exibido no canto inferior direito
	 * 
	 */ 
	public class WindowNotification extends Panel
	{
		
		
		private var blurIn:WipeUp;
		
		private var timerClose:Timer;
		
		public function WindowNotification()
		{
			super();
		}
		
		public function open():void{
			
			PopUpManager.addPopUp(this, DisplayObject(Application.application));
			PopUpManager.centerPopUp(this);
			this.y = 115;
			this.horizontalCenter = 0;
			this.verticalCenter = 0;
			
			blurIn = new WipeUp();
			//blurIn.zoomWidthFrom = 0.01;
			blurIn.duration = 600;
			blurIn.play([this]);
			
			var xWin:Number = Application.application.width - this.width;
			var yWin:Number = Application.application.height - this.height;
			
			this.x = xWin;
			this.y = yWin;
			
			setTimeout(close, 10000);
			
		}
		
		private function close():void{
			
			//Criando o efeito para ser exibido ao fechar a janela
			var fade:Fade = new Fade();
			fade.duration = 600;
			fade.alphaFrom=1.0;
			fade.alphaTo=0.0;
			fade.play([this]);
			
			//Timer para após a finalizaçao do efeito acionar a remocao do Panel
			timerClose = new Timer(601, 1);
			
			timerClose.addEventListener(TimerEvent.TIMER, removePopup);
			timerClose.start();
			
			
		}
				
		/**
		 * 
		 * Retira o panel da tela, é disparado pelo timer
		 */
		private function removePopup(e:TimerEvent):void{
			
			PopUpManager.removePopUp(this);
			timerClose.stop();
		}
		
		
		
		
		
		
	}
}